﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Convertor.Interface;
using Wpf.CommonTools;
using Wpf.CommonTools.SystemExtension;

namespace Convertor
{
    class PluginTypesConverter : IMultiValueConverter
    {
        #region IMultiValueConverter 成员

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            Collection<string> disablePluginList = values[1] as Collection<string>;
            string[] allTypes = new string[] { UILanguage.FindResource("All").ToString() }
                .Union((((ObservableDictionary<string, object>)values[0])).Where(p => !disablePluginList.Contains(p.Key)).Select(p => ((IPluginInfo)p.Value).Name.Split('-')[0]).GroupBy(p => p).Select(p => p.Key).OrderBy(p => p)).ToArray();
            return allTypes;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
